using UnityEngine;
using System.Collections;

public class ActionsControl
{
    #region variables acciones

    private ActionConstants.Action activeAction;            // accion en uso
    
    private ActionPush actionPush;

    #endregion

    public ActionsControl()
    {
        actionPush = ActionPush.Instance;

    }

    // cuando se pulsa tecla accion por primera vez
    public bool StartAction(ActionConstants.Action accion)
    {
        
        switch (accion)
        {
            case ActionConstants.Action.NONE:
                Debug.Log("No hay accion");
                return false;

            case ActionConstants.Action.ACTION_PUSH:
                if (actionPush.isUnlocked)
                {
                    actionPush.StartAction();
                }
                else
                {
                    Debug.Log("Accion BLOQUEADA");
                    return false;
                }
                break;

            default:
                Debug.Log("No hay accion");
                return false;
        }

        activeAction = accion;
        return true;
    }

    // onupdate mientras haya una accion activa
    public void doAction(PlayerControl pc, GameObject go)
    {
        switch (activeAction)
        {
            case ActionConstants.Action.NONE:
                Debug.Log("No hay accion");
                break;
            case ActionConstants.Action.ACTION_PUSH:
                if (actionPush.isUnlocked)
                {
                    actionPush.doAction(pc, go);
                }
                else
                {
                    Debug.Log("Accion BLOQUEADA");
                }
                break;

            default:
                Debug.Log("No hay accion");
                break;
        }
    }

    public void finishAction()
    {
        switch (activeAction)
        {
            case ActionConstants.Action.NONE:
                Debug.Log("No hay accion");
                break;
            case ActionConstants.Action.ACTION_PUSH:
                actionPush.pushMode = false;
                break;

            default:
                Debug.Log("No hay accion");
                break;
        }

        activeAction = ActionConstants.Action.NONE;

    }

    public void UnlockAction(ActionConstants.Action accion)
    {
        switch (accion)
        {
            case ActionConstants.Action.NONE:
                Debug.Log("Accion NONE");
                break;
            case ActionConstants.Action.ACTION_PUSH:
                actionPush.Unlock();
                break;
        }
    }

    public void LockAction(ActionConstants.Action accion)
    {
        switch (accion)
        {
            case ActionConstants.Action.NONE:
                Debug.Log("Accion NONE");
                break;
            case ActionConstants.Action.ACTION_PUSH:
                actionPush.Lock();
                break;
        }
    }


}
